import CryptoJS from "crypto-js";



export function encrypt(word) {
    let key = process.env.VUE_APP_AES_KEY;
    let iv =  process.env.VUE_APP_AES_KEY;

    key = CryptoJS.enc.Utf8.parse(key);
    iv = CryptoJS.enc.Utf8.parse(iv);
    let encrypted = CryptoJS.AES.encrypt(word, key, {
        iv: iv,
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad.Pkcs7
    });
    return encrypted.toString();

}

export function decrypt(word) {
    let key = process.env.VUE_APP_AES_KEY;
    let iv =  process.env.VUE_APP_AES_KEY;

    key = CryptoJS.enc.Utf8.parse(key);
    iv = CryptoJS.enc.Utf8.parse(iv);


    let decrypt = CryptoJS.AES.decrypt(word,key,{
        iv: iv,
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad.Pkcs7
    });
    return decrypt.toString(CryptoJS.enc.Utf8);

}